package com.jxs.android.weiget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.jxs.android.ges.R;

public class ScrollContainer extends LinearLayout {

	public ScrollContainer(Context context) {
		this(context, null);
	}

	public ScrollContainer(Context context, AttributeSet attrs) {
		super(context, attrs);
		setupView(context);
	}

	private View loading;
	private LinearLayout container;
	private ScrollView scrollView;
	private TextView errTips;

	public void showLoaing(boolean show) {
		if (show) {
			loading.setVisibility(View.VISIBLE);
			container.setVisibility(View.GONE);
			errTips.setVisibility(View.GONE);
		} else {
			container.setVisibility(View.VISIBLE);
			loading.setVisibility(View.GONE);
			errTips.setVisibility(View.GONE);
		}
	}

	public LinearLayout getContainer() {
		return container;
	}

	public void addView(View view) {
		container.addView(view);
	}

	public void addView(View view, LayoutParams lp) {
		container.addView(view, lp);
	}

	public void setErrTip(String tips) {
		errTips.setText(tips);
		loading.setVisibility(View.GONE);
		container.setVisibility(View.GONE);
		errTips.setVisibility(View.VISIBLE);
	}

	private void setupView(Context context) {
		LayoutInflater flater = LayoutInflater.from(context);
		flater.inflate(R.layout.bu_scroll_container, this);
		loading = findViewById(R.id.loading);
		errTips = (TextView) findViewById(R.id.err_tips);
		container = (LinearLayout) findViewById(R.id.content_container);
//		scrollView = (ScrollView) findViewById(R.id.scroller);
	}

}